package mc

import (
	"gitee.com/dreamwood/ez-go/db/mgo"
)

const (
	ItemBaseEventNew           = "wms.ItemBaseNew"
	ItemBaseEventBeforeCreate  = "wms.ItemBaseBeforeCreate"
	ItemBaseEventBeforeUpdate  = "wms.ItemBaseBeforeUpdate"
	ItemBaseEventBeforeSave    = "wms.ItemBaseBeforeCreate wms.ItemBaseBeforeUpdate"
	ItemBaseEventAfterCreate   = "wms.ItemBaseAfterCreate"
	ItemBaseEventAfterUpdate   = "wms.ItemBaseAfterUpdate"
	ItemBaseEventAfterSave     = "wms.ItemBaseAfterCreate wms.ItemBaseAfterUpdate"
	ItemBaseEventDelete        = "wms.ItemBaseDelete"
	ItemBaseAccessControlEvent = "wms.ItemBaseAccessControl"
)

func GetItemBaseConfig() *mgo.DocConfig {
	return ItemBase_Config
}

var ItemBase_Config *mgo.DocConfig

func init() {
	ItemBase_Config = NewItemBaseConfig()
}
func NewItemBaseConfig() *mgo.DocConfig {
	return &mgo.DocConfig{
		ContainerKey: "wms.ItemBase",
		Fields: []string{
			"name", "category", "unit", "attributes", "skus", "version",
		},
		RelationFields: []string{
			"category", "unit", "attributes", "skus",
		},
		RelationConfigs: map[string]*mgo.DocRelation{
			"category": {
				Config:     GetItemCategoryConfig,
				DocName:    "ItemCategory",
				JoinType:   "O",
				KeyInside:  "categoryId",
				KeyOutSide: "id",
			},
			"unit": {
				Config:     GetUnitConfig,
				DocName:    "Unit",
				JoinType:   "O",
				KeyInside:  "unitId",
				KeyOutSide: "id",
			},
			"attributes": {
				Config:     GetItemAttributeConfig,
				DocName:    "ItemAttribute",
				JoinType:   "M",
				KeyInside:  "id",
				KeyOutSide: "attributesIds",
			},
			"skus": {
				Config:     GetItemSkuConfig,
				DocName:    "ItemSku",
				JoinType:   "M",
				KeyInside:  "id",
				KeyOutSide: "skusIds",
			},
		},
		FieldFilter: map[string]*mgo.DocFieldFilter{
			"default": {
				Select: []string{},
				Omit:   []string{},
			},
		},
	}
}
